﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Linq.Expressions;
using BaHuan.BusinessLayer;
using BaHuan.Common;
using BaHuan.Entities;
using System.Text.RegularExpressions;
using System.Data.Sql;


namespace BaHuan
{
    public partial class FrmTimKiem : Form
    {
        ChiNhanhKhachHangManagement chinhanhkhachhangmgt = new ChiNhanhKhachHangManagement();
        KhachHangManagement khachhangmgt = new KhachHangManagement();
        KhachHang kh = new KhachHang();
        public FrmTimKiem()
        {
            InitializeComponent();
        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {

           
            ResultObj resultObj = new ResultObj();
            resultObj = khachhangmgt.GetAllKhachHang();
            List<KhachHang> lstKhachHang =(from kh in (List<KhachHang>)resultObj.Result

                                           where kh.Ten.Contains(txtTimKiem.Text) 
                                           || kh.DiaChi.Contains(txtTimKiem.Text)
                                           || kh.MaSoThue.Contains(txtTimKiem.Text)
                                           || kh.DienThoai.Contains(txtTimKiem.Text)
                          select kh).ToList();  
                         dgvTimKiem.DataSource = lstKhachHang;
                       

         
        }

        private void txtTimKiem_TextChanged(object sender, EventArgs e)
        {  
            ResultObj resultObj = new ResultObj();
            resultObj = khachhangmgt.GetAllKhachHang();
            List<KhachHang> lstKhachHang = (from kh in (List<KhachHang>)resultObj.Result

                                            where kh.Ten.Contains(txtTimKiem.Text.ToLower())
                                            || kh.DiaChi.Contains(txtTimKiem.Text.ToLower())
                                            || kh.MaSoThue.Contains(txtTimKiem.Text.ToLower())
                                            || kh.DienThoai.Contains(txtTimKiem.Text.ToLower())
                                            select kh).ToList();
            dgvTimKiem.DataSource = lstKhachHang;
                       

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
